package com.ruoyi.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.entity.VerActivityGroup;
import com.ruoyi.mapper.VerActivityGroupMapper;
import com.ruoyi.product.domain.ProductActivity;
import com.ruoyi.product.mapper.ProductActivityMapper;
import com.ruoyi.service.VerActivityGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VerActivityGroupServiceImpl implements VerActivityGroupService{
    @Autowired
    private VerActivityGroupMapper verActivityGroupMapper;

    @Override
    public List<ProductActivity> getActivitiesByGroupId(Long groupId) {
        return verActivityGroupMapper.selectActivitiesByGroupId(groupId);
    }

    /**
     * 查询活动组
     *
     * @param id 活动组主键
     * @return 活动组
     */
    @Override
    public VerActivityGroup selectVerActivityGroupById(Long id)
    {
        return verActivityGroupMapper.selectVerActivityGroupById(id);
    }

    /**
     * 查询活动组列表
     *
     * @param verActivityGroup 活动组
     * @return 活动组
     */
    @Override
    public List<VerActivityGroup> selectVerActivityGroupList(VerActivityGroup verActivityGroup)
    {
        return verActivityGroupMapper.selectVerActivityGroupList(verActivityGroup);
    }

    /**
     * 新增活动组
     *
     * @param verActivityGroup 活动组
     * @return 结果
     */
    @Override
    public boolean insertVerActivityGroup(VerActivityGroup verActivityGroup)
    {
        verActivityGroup.setCreateTime(DateUtils.getNowDate());
        int result = verActivityGroupMapper.insertVerActivityGroup(verActivityGroup);
        return result > 0;
    }

    /**
     * 修改活动组
     *
     * @param verActivityGroup 活动组
     * @return 结果
     */
    @Override
    public int updateVerActivityGroup(VerActivityGroup verActivityGroup)
    {
        verActivityGroup.setUpdateTime(DateUtils.getNowDate());
        return verActivityGroupMapper.updateVerActivityGroup(verActivityGroup);
    }

    /**
     * 批量删除活动组
     *
     * @param ids 需要删除的活动组主键
     * @return 结果
     */
    @Override
    public int deleteVerActivityGroupByIds(Long[] ids)
    {
        return verActivityGroupMapper.deleteVerActivityGroupByIds(ids);
    }

    /**
     * 删除活动组信息
     *
     * @param id 活动组主键
     * @return 结果
     */
    @Override
    public int deleteVerActivityGroupById(Long id)
    {
        return verActivityGroupMapper.deleteVerActivityGroupById(id);
    }
}
